// 轮播图
var mySwiper = new Swiper('.swiper', {
    direction: 'horizontal', // 垂直切换选项
    loop: true, // 循环模式选项

    // 如果需要分页器
    pagination: {
        el: '.swiper-pagination',
    },

    // 如果需要前进后退按钮
    navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
    },

    // 如果需要滚动条
    scrollbar: {
        el: '.swiper-scrollbar',
    },
    autoplay: {
        delay: 2000,//1秒切换一次
    },
})
//节点函数
function $(se) {
    return document.querySelector(se)
}
function $s(se) {
    return document.querySelectorAll(se)
}
//鼠标移入轮播图停止播放
$('.swiper').addEventListener('mouseover', function () {
    mySwiper.autoplay.stop();

})
//鼠标移出轮播图继续工作
$('.swiper').addEventListener('mouseout', function () {
    mySwiper.autoplay.start();

})


//海量API背景图交互效果
//鼠标移入移出事件
let pathSrcdianstr = "" //定义路径全局变量
$s('.veryAPI ul li').forEach(function (v) {
    v.addEventListener("mouseover", function () {
        // console.log(111);
        //改变背景颜色
        v.style.backgroundColor = "pink"
        v.style.color = "#fff"
        //获取图片路径
        let path = v.children[0].children[0]
        console.log(path);
        let pathSrc = path.src
        console.log(path.src);
        //查找图片中 · 的位置
        let pathSrcdian1 = pathSrc.lastIndexOf("/")
        console.log(pathSrcdian1);
        let pathSrcdian = pathSrc.lastIndexOf(".")
        console.log(pathSrcdian);
        //以·截取路径
        pathSrcdianstr = pathSrc.slice(pathSrcdian1 + 1, pathSrcdian)

        //设置图片路径
        v.children[0].children[0].src = `../../assets/imgs/${pathSrcdianstr}-c.svg`
    })

    console.log(pathSrcdianstr, 'wwwww');
    v.addEventListener("mouseout", function () {
        //恢复背景颜色
        v.style.backgroundColor = ""
        v.style.color = ""
        v.children[0].children[0].src = `../../assets/imgs/${pathSrcdianstr}.svg`
    })
})